home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / polyplay.c < prev    next >
C/C++ Source or Header  |  2000-04-22  |  3KB  |  149 lines

  1. /***************************************************************************
  2.  
  3.   Poly-Play
  4.   (c) 1985 by VEB Polytechnik Karl-Marx-Stadt
  5.  
  6.   video hardware
  7.  
  8.   driver written by Martin Buchholz (buchholz@mail.uni-greifswald.de)
  9.  
  10. ***************************************************************************/
  11.  
  12. #include "driver.h"
  13. #include "vidhrdw/generic.h"
  14.  
  15. unsigned char *polyplay_characterram;
  16. static unsigned char dirtycharacter[256];
  17.  
  18. static int palette_bank;
  19.  
  20.  
  21. void polyplay_init_palette(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  22. {
  23.     int i;
  24.  
  25.     static unsigned char polyplay_palette[] =
  26.     {
  27.         0x00,0x00,0x00,
  28.         0xff,0xff,0xff,
  29.  
  30.         0x00,0x00,0x00,
  31.         0xff,0x00,0x00,
  32.         0x00,0xff,0x00,
  33.         0xff,0xff,0x00,
  34.         0x00,0x00,0xff,
  35.         0xff,0x00,0xff,
  36.         0x00,0xff,0xff,
  37.         0xff,0xff,0xff,
  38.     };
  39.  
  40.  
  41.     for (i = 0;i < Machine->drv->total_colors;i++)
  42.     {
  43.  
  44.         /* red component */
  45.         *(palette++) = polyplay_palette[3*i];
  46.  
  47.         /* green component */
  48.         *(palette++) = polyplay_palette[3*i+1];
  49.  
  50.         /* blue component */
  51.         *(palette++) = polyplay_palette[3*i+2];
  52.  
  53.     }
  54.  
  55.     palette_bank = 0;
  56.  
  57. }
  58.  
  59.  
  60. WRITE_HANDLER( polyplay_characterram_w )
  61. {
  62.     if (polyplay_characterram[offset] != data)
  63.     {
  64.         dirtycharacter[((offset / 8) & 0x7f) + 0x80] = 1;
  65.  
  66.         polyplay_characterram[offset] = data;
  67.     }
  68. }
  69.  
  70. READ_HANDLER( polyplay_characterram_r )
  71. {
  72.     return polyplay_characterram[offset];
  73. }
  74.  
  75.  
  76. void polyplay_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  77. {
  78.     int offs;
  79.  
  80.  
  81.     if (full_refresh)
  82.     {
  83.         memset(dirtybuffer,1,videoram_size);
  84.     }
  85.  
  86.     /* for every character in the Video RAM, check if it has been modified */
  87.     /* since last time and update it accordingly. */
  88.     for (offs = videoram_size - 1;offs >= 0;offs--)
  89.     {
  90.         int charcode;
  91.  
  92.  
  93.         charcode = videoram[offs];
  94.  
  95.         if (dirtybuffer[offs] || dirtycharacter[charcode])
  96.         {
  97.             int sx,sy;
  98.  
  99.  
  100.             /* index=0 -> 1 bit chr; index=1 -> 3 bit chr */
  101.             if (charcode < 0x80) {
  102.  
  103.                 /* ROM chr, no need for decoding */
  104.  
  105.                 dirtybuffer[offs] = 0;
  106.  
  107.                 sx = offs % 64;
  108.                 sy = offs / 64;
  109.  
  110.                 drawgfx(bitmap,Machine->gfx[0],
  111.                         charcode,
  112.                         0x0,
  113.                         0,0,
  114.                         8*sx,8*sy,
  115.                         &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  116.  
  117.             }
  118.             else {
  119.                 /* decode modified characters */
  120.                 if (dirtycharacter[charcode] == 1)
  121.                 {
  122.                     decodechar(Machine->gfx[1],charcode-0x80,polyplay_characterram,Machine->drv->gfxdecodeinfo[1].gfxlayout);
  123.                     dirtycharacter[charcode] = 2;
  124.                 }
  125.  
  126.  
  127.                 dirtybuffer[offs] = 0;
  128.  
  129.                 sx = offs % 64;
  130.                 sy = offs / 64;
  131.  
  132.                 drawgfx(bitmap,Machine->gfx[1],
  133.                         charcode,
  134.                         0x0,
  135.                         0,0,
  136.                         8*sx,8*sy,
  137.                         &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  138.  
  139.             }
  140.         }
  141.     }
  142.  
  143.  
  144.     for (offs = 0;offs < 256;offs++)
  145.     {
  146.         if (dirtycharacter[offs] == 2) dirtycharacter[offs] = 0;
  147.     }
  148. }
  149.